<?php 
namespace app\admin\controller;

use cmf\controller\AdminBaseController;
use cmf\controller\BaseController;
use think\Db;

	class WxsecrectController extends BaseController
	{
		
		function getSecrect(){
			// $obj=new RedisController;
			// $obj -> delete();
		// $data=array('appid'=>'wx0f912ae0a6bd22ea&secret=428d9485b1b696adc863e647ddcb29ce','js_code'=>'001mwwL92ZmAcO02PPL92NvuL92mwwLI','grant_type'=>'authorization_code');
			$js_code = $this->request->param('code');
			$encryptedData = $this->request->param('encryptedData');
			$iv = $this->request->param('iv');
			#$js_code='061Ldi6l20QolH0Fne5l2AFW5l2Ldi6K';
			$appid='wx0f912ae0a6bd22ea';
			$secrect='428d9485b1b696adc863e647ddcb29ce';
			$url = 'https://api.weixin.qq.com/sns/jscode2session?appid='.$appid.'&secret='.$secrect.'&js_code='.$js_code.'&grant_type=authorization_code';
		// $info = sqcurl($url, 'get', array(), array());;
//初始化
			$curl = curl_init();
    //设置抓取的url
			curl_setopt($curl, CURLOPT_URL, $url);
    //设置头文件的信息作为数据流输出
			curl_setopt($curl, CURLOPT_HEADER, 0);
			curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); //不验证证书

            curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); //不验证证书
    //设置获取的信息以文件流的形式返回，而不是直接输出。
			curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    //执行命令
			$data = curl_exec($curl);
			//echo 22222;
			// print_r($data);
    //关闭URL请求
			curl_close($curl);
    //显示获得的数据
			// print_r($data);
			// echo $url;
			$info=json_decode($data,true);
			// var_dump($info);
			// exit; 
			if(!empty($info['errcode'])){
				return '请求错误';

			}
			$session_key=$info['session_key'];
		    require '../simplewind/vendor/secrect/demo.php';
		    get_secrect($session_key,$encryptedData,$iv);

		}



















































































   }